package com.zp.collection;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

public class HashMapTest2 {
	public static void main(String[] args) {
		
		HashMap<String,String> map = new HashMap<String,String>();
		
		map.put("a","Avalue");
		map.put("b","Bvalue");
		map.put("c","Cvalue");
		
		//HashMap的keySet()方法返回key的Set类型，Set有iterator()方法可遍历；
		Set<String> set = map.keySet();
		
		for(Iterator<String> iter = set.iterator();iter.hasNext();){
			String key = iter.next(); // 得到key;
			String value = map.get(key); //根据key得到value;
			System.out.println("key="+key+"; "+"value="+value);
		}
	}
}
